#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "usermanager.h"
#include "devicemanager.h"
#include "datamonitor.h"
#include "alertmanager.h"
#include "logmanager.h"
#include "page_control.h"
#include "page_video.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void setCurrentUserRole(const QString &role);
    // 添加设置用户信息
    void setCurrentUserInfo(int userId, const QString &role);

signals:
    // 发出返回登录界面的信号
    void logoutRequested();

public slots:
    void setupAlertConnection();

    // 用户选择"退出用户"时触发
    void onExitAction();

    // 菜单项点击处理
    void onMenuClicked(QListWidgetItem *item);


private:
    Ui::MainWindow *ui;
    UserManager *usermanager;
    DeviceManager *devicemanager;
    DataMonitor *datamonitor;
    AlertManager *alertmanager;
    LogManager *logmanager;
    Page_control *page_control;
    Page_video *page_video;


    // 初始化页面设置
    void setupPages();


    QString currentUserRole;

    void applyUserPermissions();

    int currentUserId;
};

#endif // MAINWINDOW_H
